package com.sgb.kjwl.view.ui.adapter.self.logistics;

import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.GoodsManageItemData;
import com.sgb.kjwl.model.entity.transport.AffiliatedFDriverEntity;
import com.sgb.kjwl.model.entity.transport.MotorcadListEntity;
import com.sgb.kjwl.model.entity.transport.SingleItemConstant;
import com.sgb.kjwl.utils.CargoConstant;
import com.sgb.kjwl.utils.NumberUtil;

import java.util.List;

/**
 * @author: 杨畔
 * @date: 2021/7/20 15:32
 * @Description: 货源管理列表适配器
 */
public class AffiliatedFDetailsAdapter extends BaseQuickAdapter<AffiliatedFDriverEntity, BaseViewHolder> {
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public AffiliatedFDetailsAdapter(@Nullable List<AffiliatedFDriverEntity> data) {
        super( R.layout.item_shared_driver, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, AffiliatedFDriverEntity item) {
        helper.addOnClickListener(R.id.cl_item_cm);
        helper.setText(R.id.tv_shared_driver_name,item.getName());
        helper.setVisible(R.id.tv_shared_driver_age,TextUtils.isEmpty(item.getAge())?false:true);
        helper.setText(R.id.tv_shared_driver_age,item.getAge()+"岁");
        helper.setVisible(R.id.tv_shared_driver_age_name,TextUtils.isEmpty(item.getDrivingYears())?false:true);
        helper.setText(R.id.tv_shared_driver_age_name,item.getDrivingYears()+"年驾龄");
        if (TextUtils.isEmpty(item.getImgUrl())) {
            helper.setImageResource(R.id.iv_avatar,R.drawable.geren_person_touxiang);
            helper.setBackgroundRes(R.id.iv_avatar,R.drawable.geren_person_touxiang);
            return;
        }
        Glide.with(helper.itemView).load(item.getImgUrl())
                .apply(new RequestOptions().centerCrop())
                .into((ImageView) helper.getView(R.id.iv_avatar));

    }
}
